package com.cropdoctor.controller;

import com.cropdoctor.common.Result;
import com.cropdoctor.model.constants.PageParams;
import com.cropdoctor.model.dto.AddOrUpdateVegeFrutableDto;
import com.cropdoctor.model.po.CategoryPo;
import com.cropdoctor.model.po.VegeFrutablePo;
import com.cropdoctor.model.vo.VegeFrutableVO;
import com.cropdoctor.service.VegeFruTableService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;

import java.io.IOException;
import java.util.List;

@RestController
@Api(tags = "果蔬花园:总体模块")
@RequestMapping("/table")
public class VegAndFruTableController {
    @Autowired
    VegeFruTableService vegeFruTableService;
    @GetMapping("/category")
    public Result<List<CategoryPo>> getCategories(@RequestParam(required = false,defaultValue = "") String mt) {
        return vegeFruTableService.getCategories(mt);
    }
    @GetMapping("/detail")
    @ApiOperation("点击具体某个果蔬后返回详细信息")
    public Result<VegeFrutablePo> getById(@RequestParam int id){
        return vegeFruTableService.getByVegeFruId(id);
    }

    @GetMapping("")
    @ApiOperation(value = "通过此接口获取果蔬实体")
    public Result<VegeFrutableVO> getAll(@RequestParam(required = false,value = "mt",defaultValue = "") String mt,
                                         @RequestParam(required = false,value = "st",defaultValue = "") String st,
                                         @RequestParam(required = false,value = "keyword",defaultValue = "") String keyword,
                                         @RequestParam int pageNo,
                                         @RequestParam int pageSize){
        PageParams pageParams = new PageParams(pageNo, pageSize);
        return vegeFruTableService.getVegeFruList(mt,st,keyword,pageParams);
    }
}
